A step by step LED lamp DIY guide for smart home

Created: 2017-09-23 Sat 22:17

Self Intro

  • make a living as digital IC design engineer
  • long-time GNU/Linux user
  • maintainer(one of) of SHLUG

WHY?

Why DIY if you can buy?

there're smart bulbs

bedroom light

without lampshade

what's wrong?

not BRIGHT enough ~1000ml ≈ 75W incandescent light bulb

requirement

  • bright, very bright
  • wireless control(on/off, brightness)
  • color temperature tunable
  • light reflect from ceiling, so product soft light

HOW?

  • hardware
  • firmware
  • software(optional)

Hardware

  • controller
  • light source
  • misc
  • tools

controller

wireless control

  • wifi
  • bluetooth
  • RF/zigbee/…

esp8266

pros

  • cheap
  • resource, or document
  • community
  • with mostly free(as freedom) SDK & develop tools

cons

  • difficult to develop program
    • alien arch: xtensa lx106
    • lwIP network stack
  • limited hardware resource
    • 80MHz/160MHz CPU
    • 160KiB RAM

brightness control

  • PWM
  • current control

PWM

https://en.wikipedia.org/wiki/Pulse-width_modulation

color temperature control

  • use both white & yellow LED source

light source

  • high power LED, white & yellow(warm white)
  • driver LED directly, accept AC, with PWM control

LEDs

driver

NOTE: driver & LED should match

misc

other necessary parts

power supply

passive cooling, be quiet

cooling, cont.

chain

hook

connector

wire

and …

tools

drill

soldering iron

photos

(view with geeqie)

Firmware

SDK

https://github.com/pfalcon/esp-open-sdk

flash tool

esptool.py(from official site)

https://github.com/espressif/esptool

C program

  • no dynamic mem alloc
  • connect to wifi router when startup
  • accept tcp connection
  • translate command to dual channel pwm output and response to command

commands

Software(optional)

integration

Home Assistant

mqtt

A lightweight message queue bridge HA & custom devices

command converter

  • connect to LED
    • periodicly query state to avoid timeout
  • connect to mqtt
    • convert mqtt message to tcp command
    • convert tcp response to mqtt message

References & Resources